package com.jtny.nytb.weather.controller;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.jtny.component.annotation.LoginFunction;
import com.jtny.component.entity.PageParam;
import com.jtny.component.entity.WebResponse;
import com.jtny.nytb.weather.entity.vo.RequestParamInfoVO;
import com.jtny.nytb.weather.entity.vo.ResponseParamInfoVO;
import com.jtny.nytb.weather.entity.vo.WeatherApiInfoPageQueryParamVO;
import com.jtny.nytb.weather.entity.vo.WeatherApiInfoVO;
import com.jtny.nytb.weather.service.WeatherSourcesService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@Api(value = "天气信息来源管理", tags = "天气信息来源管理")
@RestController
@RequestMapping("/weatherSources")
public class WeatherSourcesController {

    @Resource
    private WeatherSourcesService weatherSourcesService;

    @ApiOperation("新增天气来源信息")
    @ApiImplicitParam(name = "weatherApiInfoVO", value = "天气信息", required = true, paramType = "query", dataType = "WeatherApiInfoVO")
    @ApiOperationSupport(order = 1)
    @PostMapping("/saveApiInfo")
    @ResponseBody
    public WebResponse<?> saveApiInfo(@RequestBody WeatherApiInfoVO weatherApiInfoVO) {
        weatherSourcesService.saveApiInfo(weatherApiInfoVO);
        return WebResponse.success("操作成功");
    }

    @ApiOperation("删除天气来源信息")
    @ApiImplicitParam(name = "id", value = "主键id", required = true, paramType = "path")
    @ApiOperationSupport(order = 2)
    @GetMapping("/deleteApiInfo/{id}")
    @ResponseBody
    public WebResponse<?> deleteApiInfo(@PathVariable Long id) {
        weatherSourcesService.deleteApiInfo(id);
        return WebResponse.success("操作成功");
    }

    @ApiOperation("修改天气来源信息")
    @ApiImplicitParam(name = "weatherApiInfoVO", value = "天气信息", required = true, paramType = "query", dataType = "WeatherApiInfoVO")
    @ApiOperationSupport(order = 3)
    @PostMapping("/updateApiInfo")
    @ResponseBody
    public WebResponse<?> updateApiInfo(@RequestBody WeatherApiInfoVO weatherApiInfoVO) {
        weatherSourcesService.updateApiInfo(weatherApiInfoVO);
        return WebResponse.success("操作成功");
    }

    @ApiOperation("查询单个天气来源信息")
    @ApiImplicitParam(name = "id", value = "主键id", required = true, paramType = "path")
    @ApiOperationSupport(order = 4)
    @GetMapping("/getApiInfo/{id}")
    @ResponseBody
    public WebResponse<?> getApiInfo(@PathVariable Long id) {
        return WebResponse.success("操作成功", weatherSourcesService.selectApiById(id));
    }

    @ApiOperation("分页查询天气来源信息")
    @ApiImplicitParam(name = "weatherApiInfoPageQueryParamVO", value = "天气信息分页查询条件", required = true, paramType = "query", dataType = "WeatherApiInfoPageQueryParamVO")
    @ApiOperationSupport(order = 5)
    @PostMapping("/selectPageByApiInfo")
    @ResponseBody
    public WebResponse<?> selectPageByApiInfo(@RequestBody WeatherApiInfoPageQueryParamVO weatherApiInfoPageQueryParamVO) {
        return WebResponse.success("操作成功", weatherSourcesService.pageQueryByApi(weatherApiInfoPageQueryParamVO));
    }

    @ApiOperation("新增请求参数信息")
    @ApiImplicitParam(name = "requestParamInfoVO", value = "请求参数信息", required = true, paramType = "query", dataType = "RequestParamInfoVO")
    @ApiOperationSupport(order = 6)
    @PostMapping("/saveRequestParamInfo")
    @ResponseBody
    public WebResponse<?> saveRequestParamInfo(@RequestBody RequestParamInfoVO requestParamInfoVO) {
        weatherSourcesService.saveRequestParamInfo(requestParamInfoVO);
        return WebResponse.success("操作成功");
    }

    @ApiOperation("查询单个请求参数信息")
    @ApiImplicitParam(name = "id", value = "请求参数主键id", required = true, paramType = "path")
    @ApiOperationSupport(order = 7)
    @GetMapping("/selectRequestInfoById/{id}")
    @ResponseBody
    public WebResponse<?> selectRequestInfoById(@PathVariable Long id) {
        return WebResponse.success("操作成功", weatherSourcesService.selectRequestInfoById(id));
    }

    @ApiOperation("删除请求参数信息")
    @ApiImplicitParam(name = "id", value = "请求参数主键id", required = true, paramType = "path")
    @ApiOperationSupport(order = 8)
    @GetMapping("/deleteRequestParamInfo/{id}")
    @ResponseBody
    public WebResponse<?> deleteRequestParamInfo(@PathVariable Long id) {
        weatherSourcesService.deleteRequestParamInfo(id);
        return WebResponse.success("操作成功");
    }

    @ApiOperation("修改请求参数信息")
    @ApiImplicitParam(name = "requestParamInfoVO", value = "请求参数信息", required = true, paramType = "query", dataType = "RequestParamInfoVO")
    @ApiOperationSupport(order = 9)
    @PostMapping("/updateRequestParamInfo")
    @ResponseBody
    public WebResponse<?> updateRequestParamInfo(@RequestBody RequestParamInfoVO requestParamInfoVO) {
        weatherSourcesService.updateRequestParamInfo(requestParamInfoVO);
        return WebResponse.success("操作成功");
    }

    @ApiOperation("分页查询请求参数信息")
    @ApiImplicitParam(name = "pageParam", value = "请求参数分页查询条件", required = true, paramType = "query", dataType = "PageParam")
    @ApiOperationSupport(order = 10)
    @PostMapping("/pageQueryByRequestParam")
    @ResponseBody
    public WebResponse<?> pageQueryByRequestParam(@RequestBody PageParam pageParam) {
        return WebResponse.success("操作成功", weatherSourcesService.pageQueryByRequestParam(pageParam));
    }

    @ApiOperation("根据apiId查询请求参数信息")
    @ApiImplicitParam(name = "apiId", value = "api接口信息主键id", required = true, paramType = "path")
    @ApiOperationSupport(order = 11)
    @PostMapping("/selectRequestByApiId/{apiId}")
    @ResponseBody
    public WebResponse<?> selectRequestByApiId(@PathVariable Long apiId) {
        return WebResponse.success("操作成功", weatherSourcesService.selectRequestByApiId(apiId));
    }

    @ApiOperation("新增返回参数信息")
    @ApiImplicitParam(name = "responseParamInfoVO", value = "返回参数信息", required = true, paramType = "query", dataType = "ResponseParamInfoVO")
    @ApiOperationSupport(order = 12)
    @PostMapping("/saveResponseParamInfo")
    @ResponseBody
    public WebResponse<?> saveResponseParamInfo(@RequestBody ResponseParamInfoVO responseParamInfoVO) {
        weatherSourcesService.saveResponseParamInfo(responseParamInfoVO);
        return WebResponse.success("操作成功");
    }

    @ApiOperation("查询单个返回参数信息")
    @ApiImplicitParam(name = "id", value = "返回参数主键id", required = true, paramType = "path")
    @ApiOperationSupport(order = 13)
    @GetMapping("/selectResponseInfoById/{id}")
    @ResponseBody
    public WebResponse<?> selectResponseInfoById(@PathVariable Long id) {
        return WebResponse.success("操作成功", weatherSourcesService.selectResponseInfoById(id));
    }

    @ApiOperation("删除返回参数信息")
    @ApiImplicitParam(name = "id", value = "返回参数主键id", required = true, paramType = "path")
    @ApiOperationSupport(order = 14)
    @GetMapping("/deleteResponseParamInfo/{id}")
    @ResponseBody
    public WebResponse<?> deleteResponseParamInfo(@PathVariable Long id) {
        weatherSourcesService.deleteResponseParamInfo(id);
        return WebResponse.success("操作成功");
    }

    @ApiOperation("修改返回参数信息")
    @ApiImplicitParam(name = "responseParamInfoVO", value = "返回参数信息", required = true, paramType = "query", dataType = "ResponseParamInfoVO")
    @ApiOperationSupport(order = 15)
    @PostMapping("/updateResponseParamInfo")
    @ResponseBody
    public WebResponse<?> updateResponseParamInfo(@RequestBody ResponseParamInfoVO responseParamInfoVO) {
        weatherSourcesService.updateResponseParamInfo(responseParamInfoVO);
        return WebResponse.success("操作成功");
    }

    @ApiOperation("分页查询返回参数信息")
    @ApiImplicitParam(name = "pageParam", value = "返回参数分页查询条件", required = true, paramType = "query", dataType = "PageParam")
    @ApiOperationSupport(order = 16)
    @PostMapping("/pageQueryByResponseParam")
    @ResponseBody
    public WebResponse<?> pageQueryByResponseParam(@RequestBody PageParam pageParam) {
        return WebResponse.success("操作成功", weatherSourcesService.pageQueryByResponseParam(pageParam));
    }

    @ApiOperation("根据apiId查询返回参数信息")
    @ApiImplicitParam(name = "apiId", value = "api接口信息主键id", required = true, paramType = "path")
    @ApiOperationSupport(order = 17)
    @PostMapping("/selectResponseByApiId/{apiId}")
    @ResponseBody
    public WebResponse<?> selectResponseByApiId(@PathVariable Long apiId) {
        return WebResponse.success("操作成功", weatherSourcesService.selectResponseByApiId(apiId));
    }
}
